<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
Ext.onReady(function() {
	
	Ext.QuickTips.init();
	
	var top=Ext.widget({
		 xtype: 'form',
	        layout: 'form',
	        renderTo:'updatesecuit',
	        frame:true,
	        fieldDefaults: {
	            msgTarget: 'qtip',
	            labelWidth: 80
	        },
	        defaultType: 'textfield',
	        items: [{
	        	id:'displayName',
	            fieldLabel: '姓名',
	            name: 'secuit.displayName',
	            allowBlank: false
	        },{
	        	id:'age',
	            fieldLabel: '年龄',
	            name: 'secuit.age',
	            allowBlank: false
	        },{
	        	id:'phont',
	            fieldLabel: '电话',
	            name: 'secuit.phont',
	            allowBlank: false
	        },{
	        	id:'EMail',
	            fieldLabel: '邮箱',
	            name: 'secuit.EMail',
                vtype:'email',
	            allowBlank: false
	        },{
	        	id:'school',
	            fieldLabel: '学校',
	            name: 'secuit.school',
	            allowBlank: false
	        },{
	        	xtype: 'datefield',
	        	id:'visitTime',
	            fieldLabel: '到访时间',
                format: 'Y-m-d', 
	            name: 'secuit.visitTime',
	            allowBlank: false
	        },{
	        	xtype: 'datefield',
	        	id: 'createTime',
	        	hidden: true,
	        	format: 'Y-m-d',
	        	name: 'secuit.createTime'
	        },{
	        	id: 'createUserId',
	        	name: 'secuit.createUserId',
	        	hidden: true
	        }],

        buttons: [{
            text: '保存',
            handler: function() {
       			this.up('form').getForm().submit({  
                    url : '../service/secuit_update',//请求的url地址  
                    params: {id: Ext.getDom('secuitid').value},
                    method:'post',//请求方式
                    success:function(form,action){//加载成功的处理函数  
	                   	Ext.Msg.alert('提示', action.result.msg);
	                   	this.up('form').getForm().reset();
               		},
                    failure:function(form,action){//加载成功的处理函数  
  		        		Ext.Msg.alert('提示', action.result.msg); 
   		        	}
                });
        	}
        },{
        	text: '重置',
            handler: function() {
            	this.up('form').getForm().reset();
            }
        }],
        listeners:{
        	'render':function(){
        		Ext.Ajax.request({
        		    url: '../service/secuit_find',
        		    params: {
        		        id: Ext.getDom('secuitid').value
        		    },
        		    success: function(response, opts) {
        		        var obj = Ext.decode(response.responseText);
        		        Ext.getCmp('displayName').setValue(obj.secuit.displayName);
        		        Ext.getCmp('phont').setValue(obj.secuit.phont);
        		        Ext.getCmp('age').setValue(obj.secuit.age);
        		        Ext.getCmp('school').setValue(obj.secuit.school);
        		        Ext.getCmp('EMail').setValue(obj.secuit.EMail);
        		        var vtime=obj.secuit.visitTime.split('T')[0];
        		        Ext.getCmp('visitTime').setValue(vtime);
        		        var ctime=obj.secuit.createTime.split('T');
        		        Ext.getCmp('createTime').setValue(ctime[0]);
        		        Ext.getCmp('createUserId').setValue(obj.secuit.createUserId);
        		    },
        		});
        	}
        }
    });
});
</script>
</head>
<body>
<input type="hidden" id="secuitid" value="<s:property value='id'/>"/>
<div id="updatesecuit"></div>
</body>
</html>